package com.briup.serviceImp;

import com.briup.dao.AddressMapper;
import com.briup.pojo.Address;
import com.briup.service.IAddressService;
import com.briup.utils.ToolMan;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class AddressserviceImp implements IAddressService {
    @Override
    public List<Address> findByCustomer(Integer id) {
        SqlSession sqlSession = ToolMan.getSqlSession();
        AddressMapper mapper = sqlSession.getMapper(AddressMapper.class);
       List<Address> addresses = mapper.selectByCustomerId(id);
       sqlSession.close();
       return addresses;
    }

    @Override
    public void saveAddress(Address address) {
        SqlSession sqlSession = ToolMan.getSqlSession();
        AddressMapper mapper = sqlSession.getMapper(AddressMapper.class);
        int insert = mapper.insert(address);
        ToolMan.close(sqlSession);
    }
}
